package com.quasar.hpatient.view.adapter.render;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ada.adapter.RenderBuiler;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.medicalmodel.PrescriptionDayData;
import com.vise.log.ViseLog;

/**
 * name : lishuai
 * time : 2017/12/21
 * title:
 */

public class Pharmacy_Record_RenderBuiler extends RenderBuiler<PrescriptionDayData.ListBean> {


    private TextView title; //医院名称
    private TextView doctor; //医生姓名
    private TextView time; //时间
    private TextView desc; //内容
    private TextView demo;// 编辑内容


    public Pharmacy_Record_RenderBuiler(Context context) {
        super(context);
    }

    @Override
    public void render() {

        if (getContent() != null) {
            StringBuffer buf = new StringBuffer();

            StringBuffer edit = new StringBuffer();
            if (getContent().getPerscriptDetailList() != null && getContent().getPerscriptDetailList().size() > 0) {
                int num = getContent().getPerscriptDetailList().size();
                ViseLog.d("患者添加" + num);

                for (int i = 0; i < num; i++) {
                    time.setText(getContent().getPerscriptDetailList().get(i).getPrescriptionIndex().getEditTime());  //获取药单创建时间

                    if (getContent().getPerscriptDetailList().get(i).getName() != null && getContent().getPerscriptDetailList().get(i).getName().length() > 0) {
                        title.setText(getContent().getPerscriptDetailList().get(i).getName());
                    } else {
                        title.setText(" ");
                    }
                    if (getContent().getPerscriptDetailList().get(i).getRName() != null & getContent().getPerscriptDetailList().get(i).getRName().length() > 0) {
                        doctor.setText(getContent().getPerscriptDetailList().get(i).getRName() + "");
                    } else {
                        doctor.setText("患者添加");
                    }
                    int numbers = getContent().getPerscriptDetailList().get(i).getPrescriptionDoseDetail().size();
                    buf.append(getContent().getPerscriptDetailList().get(i).getMName() + "\t" + "一天" + numbers + "次" + "\n");
                }
                if (getContent().getPrescriptionEditHistroyList() != null) {
                    for (int a = 0; a < getContent().getPrescriptionEditHistroyList().size(); a++) {
                        edit.append(getContent().getPrescriptionEditHistroyList().get(a).getEidtMessage() + "\n");
                    }
                }
                desc.setText(buf.toString() + ""); //内容
                demo.setText(edit.toString() + ""+"\n");  //编辑
            }
        }
    }

    @Override
    protected void setUpView(View view) {
        title = (TextView) view.findViewById(R.id.title);
        doctor = (TextView) view.findViewById(R.id.doctor);
        time = (TextView) view.findViewById(R.id.time);
        desc = (TextView) view.findViewById(R.id.desc);
        demo = (TextView) view.findViewById(R.id.demo);
    }

    @Override
    protected void hookListeners(View view) {

    }

    @Override
    protected int getlayoutid() {
        return R.layout.pharmacy_record_items;
    }
}
